import { Component, defineComponent, ref } from 'vue';
import { ConfigProvider, Modal } from 'ant-design-vue';
import zhCN from 'ant-design-vue/es/locale/zh_CN';
import type { ModalProps, ModalFuncProps } from 'ant-design-vue';
export const cp = (
  component: Component,
  propsss: ModalProps | ModalFuncProps,
) => {
  return defineComponent({
    setup() {
      const visible = ref(true);
      // const vNode = h(component);
      // const box = document.createElement('div');
      // vNode.appContext = appContext;
      // render(vNode, box);
      return {
        visible,
        // vNode,
      };
    },
    render() {
      return (
        <div>
          <ConfigProvider locale={zhCN}>
            <Modal
              v-model:open={this.visible}
              cancelText="取消"
              okText="确定"
              {...propsss}
            >
              {/*<div id="box">{this.vNode}</div>*/}
              {component}
            </Modal>
          </ConfigProvider>
        </div>
      );
    },
  });
};
